package com.awesome.spring.function.sink;

import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.functions.sink.RichSinkFunction;

/**
 * @program: awesome-spring
 * @description: 输出类
 * @author: Alex Wu
 * @createDate: 2025-03-20 15:39
 **/
public class BehaviorLogSinkFunc extends RichSinkFunction<String> {


    @Override
    public void open(Configuration parameters) throws Exception {
        super.open(parameters);
        // 初始化: 打开数据库连接
        System.out.println("初始化: 打开数据库连接");
    }

    @Override
    public void invoke(String value, Context context) throws Exception {
        // 输出数据
        System.out.println("落库: " + value);
    }

    @Override
    public void close() throws Exception {
        super.close();
        // 关闭连接和 PreparedStatement
        System.out.println("关闭连接和 PreparedStatement");
    }

}
